<?php

// 4/10/2010: immanuel192 write this modeler
class slide_item {
	function form($object, $song_collection = 0) {
		if (!defined('SYS_FORMS')) require_once(BASE.'subsystems/forms.php');
		exponent_forms_initialize();

		$form = new form();
		global $db;
		
		if (!isset($object->id)) {
			$object->name = '';
			$object->collection_id=0;
			$object->song_no=0;
		} else {
			$form->meta('id',$object->id);
		}
		
		$collection=$db->selectDropdown("present_song_collection","name");
		
		$form->register('name','Name',new textcontrol($object->name));
		
		$collection_default=$song_collection;
		
		if (isset($object->id))
			$collection_default=$object->collection_id;
		foreach ($collection as $key=>$value) {
			if ($key == $collection_default)
			{ $object->collection_id=$key; break; }
		}
		
		$form->register('collection_id',"Collection",new dropdowncontrol($object->collection_id,$collection));
		$form->register('song_no','Song number',new textcontrol($object->song_no));
		$form->register('goto_verse','Edit verses after complete',new checkboxcontrol(true));
		$form->register('submit','',new buttongroupcontrol('Save','','Cancel'));
		return $form;
	}

	function update($values,$object) {
		$object->name = $values['name'];
		$object->song_no = intval($values['song_no']);
		$object->collection_id = $values['collection_id'];
		return $object;
	}
}

?>
